This folder contains a working example plugin for PCAutomation / Smap3D P&ID. Use it as a starting point for your own plugin by following the steps below in order.
To make PCAutomation / Smap3D P&ID aware of your plugin, a few "identity" values need to be set up correctly — that's what most of this guide is about.
.MIF file to match, and give your plugin a name.Steps 1, 2 and 5 are things you only do once per plugin. After that, you can rebuild and test as often as you like without repeating them (unless noted otherwise below).
Before you change anything, it's worth going through Steps 4-6 below once with the template exactly as you received it (it's a working test plugin on its own — it just shows a small demo window with a list). That way, if something doesn't work later while you're building your own plugin, you already know your machine, Visual Studio, and PCAutomation / Smap3D P&ID setup are all fine, and the problem is something in your own changes rather than the environment.
So: skip ahead to Step 4 (Build), then Step 5 (Register), then Step 6 (Install), and confirm the demo plugin shows up under Tools and opens a small window when clicked. Once that works, come back here and continue with Step 1 to turn it into your own plugin.
Windows identifies COM components (like this plugin) using a GUID — a long, unique code that
looks like {8FBDD806-182B-4D5C-82F3-491AA7057001}. Think of it as a serial number: if two
different plugins accidentally use the same GUID, Windows won't be able to tell them apart, and
things will behave unpredictably. That's why the very first thing you must do is generate a
new, unique GUID for your plugin.
Open PCsTestPlugin.cs and look near the bottom of the file for this:
[Guid("8FBDD806-182B-4D5C-82F3-491AA7057001")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public sealed class PCsPlugin : IPCsPluginSimple
You need to replace 8FBDD806-182B-4D5C-82F3-491AA7057001 with a new GUID of your own.
How to generate a new GUID:
PowerShell, press Enter).[guid]::NewGuid()
[Guid("...")] line above, replacing the old value, keeping the
surrounding quotes.⚠️ Do not touch the other GUID in this file — the one on the
IPCsPluginSimpleinterface (7020B4F9-25D5-47AF-BAAB-BFE710DD32AA). That one is fixed and owned by PCAutomation / Smap3D P&ID itself; it's how the program recognizes any plugin. Only the GUID on yourPCsPluginclass (your plugin's own identity) should be changed.
Write your new GUID down somewhere — you'll need the exact same value again in Step 2.
.MIF fileThe .MIF file (PCsPluginTestDLL_Modal.MIF) is a small text file that tells PCAutomation /
Smap3D P&ID about your plugin: what it's called, which menu it should appear in, and which GUID
to activate when it's clicked.
Open it in Notepad and you'll see something like this:
[Modul]
Title=Test Modal Plugin
[Plugin]
Menu1=Tools
Name1=Test Modal Plugin
Cmd1={8FBDD806-182B-4D5C-82F3-491AA7057001}
Index1=200
Make these changes:
| Field | What to change it to |
|---|---|
Title |
The name of your plugin, as you want it to appear in File → Modules. |
Name1 |
The name of your plugin, as you want it to appear in the Tools menu. Can be the same as Title. |
Cmd1 |
The exact same GUID you generated in Step 1, in curly braces {...}. This is what links the MIF file to your plugin's code. |
Menu1 |
Which menu the plugin appears under (Tools is a safe default). |
Index1 |
Sort order within that menu — any number works, lower numbers appear first. |
Do not change the section headers [Modul] and [Plugin] — PCAutomation / Smap3D P&ID
looks for those exact names (note it's [Modul], not the English "Module").
⚠️ Important — saving the file: the
.MIFfile must be saved as Unicode text, not plain ANSI/UTF-8 text. In Notepad: File → Save As, then set the Encoding dropdown (bottom right of the Save dialog) to Unicode, and save over the existing file. If you save it with the wrong encoding, your plugin will show up in the Modules list with its file path instead of its proper name (see Troubleshooting below).
Still in PCsTestPlugin.cs, look at the Execute() method:
public bool Execute()
{
form = new Form();
form.Text = "Test custom window " + ...;
ListView listView = new ListView();
...
form.ShowDialog(new Win32Window(windowHandle));
return true; // always return true - see note below
}
This method runs whenever a user clicks your plugin in the Tools menu. Replace the demo
ListView/Form code with whatever your plugin should actually do. A few notes:
SetPCsApplication(...) is called automatically before Execute(), and gives you pcsApp —
your handle to talk back to PCAutomation / Smap3D P&ID (e.g. pcsApp.GetMainWindowHandle()).
Leave this method as-is.Execute() returning true. Returning false keeps the plugin resident in
memory for the rest of the session instead of releasing it - an advanced option that's out of
scope for this guide, and best avoided unless you know both why you need it and how to handle
it correctly.PCsPluginTestDLL_Modal.sln in Visual Studio.Ctrl+Shift+B).The project is already set up to automatically copy the built files to
C:\PCAutomation\ after every build. If PCAutomation / Smap3D P&ID is installed somewhere else
on your machine, please change the destination path.
Before Windows will let PCAutomation / Smap3D P&ID load your plugin, you need to tell Windows where to find it. This is a one-time step called COM registration, and only needs to be repeated if you later change your plugin's GUID or move its files to a different folder — a normal rebuild does not require re-registering.
Register.bat (in the Source folder).To remove the plugin later, use Unregister.bat the same way.
⚠️ If PCAutomation / Smap3D P&ID is installed somewhere other than
C:\PCAutomation\, openRegister.batandUnregister.batin a text editor first, and update the file path in each of them to match the folder your build output actually gets copied to (the same folder you set up in Step 4).
Title you set in the .MIF file).Your plugin will now show up in the Tools menu. Click it to try it out.
| Problem | Likely cause |
|---|---|
| "Class not registered" error when clicking the plugin | You skipped Step 5, or the GUID in PCsTestPlugin.cs doesn't match the one you registered. Rebuild, then run Register.bat again. |
| The Modules list shows a file path instead of your plugin's name | The .MIF file wasn't saved as Unicode, or the [Modul] section header was changed/misspelled. Re-open it and re-save with the Unicode encoding as described in Step 2. |
| Plugin doesn't appear in File → Modules at all | The .MIF file wasn't copied to PCAutomation / Smap3D P&ID's folder. Rebuild the project (Step 4) and check the file landed in the right place, or copy it there by hand. |
| Plugin installed, but doesn't show up in the Tools menu | Make sure you clicked Install in File → Modules (not just selected it), then restart PCAutomation / Smap3D P&ID. |
| Nothing happens, or odd/unexpected behavior between two different plugins | Double-check your class's GUID is actually unique — a common mistake is forgetting to change it after copying the template. |
If you're only building a single plugin, you don't need to rename anything — changing the GUID
(Step 1) and the .MIF file (Step 2) is enough. But if you plan to build several different
plugins from copies of this template, you should also rename the project so their built files
don't overwrite each other. That means renaming, consistently, in all of these places:
.csproj and .sln file names..MIF file name.AssemblyName and RootNamespace inside the .csproj.CopyOutputToPcAutomation build step inside the .csproj.PCsPluginTestDLL_Modal).Register.bat and Unregister.bat.If you're not comfortable making all of those changes consistently, it's simplest to just keep one plugin per copy of this template folder.